package com.xq.sboot.amqp;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 功能说明: SpringBoot应用程序类.
 * <p>创建时间: 2019-01-02 16:38</p>
 *
 * @author 郭凯强
 * @version 1.0-SNAPSHOT
 */
@SpringBootApplication
@EnableScheduling
public class Application {
    private final Logger logger = LoggerFactory.getLogger(Application.class);
    
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Profile("usage_message")
    @Bean
    public CommandLineRunner usage() {
        return args -> {
            logger.info("This app uses Spring Profiles to control its behavior.\n");
            logger.info("Options are: ");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=hello-world,receiver");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=hello-world,sender");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=work-queues,receiver");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=work-queues,sender");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=pub-sub,receiver");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=pub-sub,sender");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=routing,receiver");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=routing,sender");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=topics,receiver");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=topics,sender");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=rpc,client");
            logger.info("java -jar rabbit-tutorials.jar --spring.profiles.active=rpc,server");
        };
    }

    @Profile("!usage_message")
    @Bean
    public CommandLineRunner tutorial(){
        return new RabbitAmqpTutorialsRunner();
    }
}
